/*******************************************************************************
 * Copyright (c) 2010 Sylvain Sicard.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Sylvain Sicard - initial API and implementation
 ******************************************************************************/
package com.googlecode.ssdutils.beanconverter.example.presentation.table;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import org.springframework.beans.factory.InitializingBean;

/**
 * @author Sylvain Sicard
 * 
 */
public class ItemTableUpdater implements InitializingBean {

	private JTable itemTable;

	private JTable listTable;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
	 */
	public void afterPropertiesSet() throws Exception {
		ListSelectionModel rowSM = listTable.getSelectionModel();
		rowSM.addListSelectionListener(new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent e) {
				itemTable.revalidate();
				itemTable.repaint();
			}
		});
	}

	public void setItemTable(JTable itemTable) {
		this.itemTable = itemTable;
	}

	public void setListTable(JTable listTable) {
		this.listTable = listTable;
	}
}
